sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/ui/core/routing/History",
	"sap/ui/model/json/JSONModel",
], (Controller, History, JSONModel) => {
	"use strict";

	return Controller.extend("ui5.walkthrough.controller.detail.Param", {
		onInit() {
			const oRouter = this.getOwnerComponent().getRouter();
			oRouter.getRoute("param").attachPatternMatched(this._onObjectMatched, this);
			// 路径
		},

		_onObjectMatched(oEvent) {
			var oArgs = oEvent.getParameter("arguments");
			let par = {
				param1: oArgs.param1,
				param2: oArgs.param2,
			}
			const oModel = new JSONModel(par);
			this.getView().setModel(oModel, 'par');
			console.log(this.getView().getModel('par'));
		},

		onPageNavButtonPress() {
			const oHistory = History.getInstance();
			const sPreviousHash = oHistory.getPreviousHash();

			if (sPreviousHash !== undefined) {
				window.history.go(-1);
			} else {
				const oRouter = this.getOwnerComponent().getRouter();
				oRouter.navTo("overview", {});
				// 没有上一画面时，跳转到overview画面
			}
		}
	});
});